/*
 * @Description:
 * @Author: zhaolei
 * @Date: 2023-04-13 14:51:20
 */
import {
  BROADCAST_TYPE_LIST,
  BROADCAST_TYPE,
  REPORTING_CONTENT_TYPE_LIST,
} from '@/const/type';
export const tableOption = (typeList = [], isComment, view) => {
  return {
    ...window.$crudMixins.tableOptions,
    addBtn: false,
    editBtn: false,
    delBtn: false,
    menuWidth: 120,
    searchLabelWidth: 130,
    labelWidth: 130,
    viewBtn: false,
    detail: true,
    column: [
      {
        type: 'select',
        label: '举报内容类型',
        prop: 'objType',
        search: true,
        dicData: REPORTING_CONTENT_TYPE_LIST,
      },
      {
        label: '内容编号',
        prop: 'id',
      },
      {
        label: '发布用户编号',
        prop: 'userCode',
        search: true,
      },
      {
        label: '发布用户昵称',
        prop: 'userNickname',
        search: true,
      },
      {
        label: '发布时间',
        prop: 'createTime',
        type: 'datetime',
        width: 160,
        format: 'yyyy-MM-dd HH:mm',
        valueFormat: 'yyyy-MM-dd HH:mm:ss',
      },
      {
        label: '内容类型',
        prop: 'type',
        search: true,
        type: 'select',
        dicData: typeList,
        display: !view,
      },
      {
        // 状态（1：正常，2：已屏蔽）
        label: '展示状态',
        prop: 'status',
        type: 'select',
        search: true,
        dicData: [
          {
            label: '正常',
            value: '1',
          },
          {
            label: '已屏蔽',
            value: '2',
          },
        ],
      },
      {
        label: '可见状态',
        prop: 'publicFlag',
        type: 'select',
        display: !view,
        dicData: [
          {
            label: '私人可见',
            value: '0',
          },
          {
            label: '公开可见',
            value: '1',
          },
        ],
      },
    ],
    group: [
      {
        label: '内容介绍',
        prop: 'group2',
        labelWidth: 0,
        column: [
          {
            label: '',
            prop: 'content',
          },
        ],
      },
      {
        label: '内容图片/视频',
        prop: 'group1',
        labelWidth: 0,
        column: [
          {
            label: '',
            prop: 'fileType',
            type: 'radio',
            row: true,
            span: 12,
            dicData: BROADCAST_TYPE_LIST,
            display: false,
            control: (val, form) => {
              if (val === BROADCAST_TYPE.PICTURE) {
                return {
                  petPicture: {
                    display: true,
                  },
                  petVideo: {
                    display: false,
                  },
                };
              } else {
                return {
                  petPicture: {
                    display: false,
                  },
                  petVideo: {
                    display: true,
                  },
                };
              }
            },
          },
          {
            label: '',
            display: true,
            prop: 'petPicture',
            type: 'upload',
            // listType: 'picture-img',
            listType: 'picture-card',
            fileSize: 5 * 1024,
            fileType: 'img', //img/video/audio
            propsHttp: {
              name: 'hash',
              url: 'key',
            },
            multiple: true,
            // action: 'http://upload-z2.qiniup.com',
            oss: 'qiniu',
            cropperOption: {
              // autoCropWidth: 187.5,
              // autoCropHeight: 250,
              enlarge: 2,
              fixed: true,
              fixedNumber: [0.75, 1],
            },
            tip: '图片类型仅支持png、jpg、jpeg，且大小不超过500k，尺寸建议166＊206，最多可上传9张图片',
            row: true,
            span: 14,
            limit: 9,
            accept: '.png, .jpg, .jpeg, .gif',
            rules: [
              { required: true, message: '请上传宣传图片', trigger: 'blur' },
            ],
          },
          // {
          //   label: '',
          //   prop: 'petVideo',
          //   type: 'upload',
          //   fileSize: 50 * 1024, // 写在这里直接拦截没有提示
          //   // listType: 'picture-card',
          //   listType: 'picture-img',
          //   fileType: 'video', //img/video/audio
          //   propsHttp: {
          //     name: 'hash',
          //     url: 'key',
          //   },
          //   // action: 'http://upload-z2.qiniup.com',
          //   oss: 'qiniu',
          //   tip: '视频时长仅支持3分钟以内，建议优先9-30秒，最多可上传1个视频',
          //   row: true,
          //   span: 14,
          //   accept: '.mp4, .mpeg, .WMV',
          //   limit: 1,
          //   rules: [
          //     { required: true, message: '请上传宣传视频', trigger: 'blur' },
          //   ],
          // },
        ],
      },
      {
        label: '被举报评论',
        prop: 'groupComment',
        labelWidth: 0,
        display: isComment,
        column: [
          {
            type: 'textarea',
            label: '',
            prop: 'commentContent',
            minRows: 7,
            span: 24,
          },
        ],
      },
    ],
  };
};
